package 哈夫曼编码;

import java.util.Comparator;
import java.util.PriorityQueue;

public class 什么是优先队列 {

	public static void main(String[] args) {
		PriorityQueue<Integer> q = new PriorityQueue<>(2, new Comparator<Integer>() {
			@Override
			public int compare(Integer o1, Integer o2) {
				return o1 < o2 ? 1 : -1;
			}
		});

		q.offer(5);
		q.offer(3);
		q.offer(2);
		q.offer(6);
		q.offer(9);
		q.offer(2);

		System.out.println(q.toString());

		while (!q.isEmpty()) {
			System.out.println(q.poll());
		}
	}

}
